<template>
	<view>
		<simple-toolbar :title="$t('asset.residual.assetResidual1')"></simple-toolbar>

		<view class="pad-base table">
			<nav-tab @change-current-tab="getData" @ready="getData" />
			<el-table :data="formData" style="width: 100%">
				<el-table-column align="center" prop="user" :label="$t('asset.residual.id')"></el-table-column>
				<el-table-column align="center" prop="coin_name" :label="$t('wallet.wallet.coin')">
					<template slot-scope="scope">
						<text>{{scope.row.coin_name}}</text>
					</template>
				</el-table-column>
				<el-table-column align="center" prop="balance" :label="$t('asset.residual.balance')"></el-table-column>
			</el-table>
		</view>
	</view>
</template>

<script>
	import {
		getUserResidual,
		getResidual
	} from "../../../js_sdk/uni-admin/asset.js"

	export default {
		data() {
			return {
				cacheCurrentTab: {
					coin: 1
				},
				formData: [],
				// coinList: []
			}
		},
		methods: {
			async getData(data) {
				this.data = data
				// this.coinList = uni.getStorageSync('coinList')
				let query = {}
				if (data) {
					query = data
					this.cacheCurrentTab = data
				} else {
					query = this.cacheCurrentTab
				}
				console.log('data', data, query)
				let res = await getUserResidual('get', query)
				this.formData = res.data
				this.formData.forEach(item => {
					item.balance = this.$utils.retain12(item.balance)
				})
			}
		},
		onShow() {
			// this.getData(this.data)
		}
	}
</script>

<style scoped>
	.box {
		display: flex;
		padding: 19.53rpx;
	}

	.item {
		background-color: #FFFFFF;
		border-radius: 4.68rpx;
		box-shadow: 0 0.78rpx 15.62rpx rgba(0, 0, 0, 0.1);
		padding: 9.37rpx;
		flex: 1;

		display: flex;
		flex-direction: column;
	}

	.item:first-child {
		margin-right: 19.53rpx;
	}

	.key {
		color: #3B3E66;
		opacity: 0.8;
		font-size: 6.25rpx;
		margin-bottom: 8.98rpx;
	}

	.value {
		color: #12A234;
		opacity: 0.8;
		font-size: 10.15rpx;
	}
</style>
